import request from '@/config/axios'

export interface QuestionListParams {
  singleChoice: any[]
  multipleChoice: any[]
  judge: any[]
  short: any[]
  blank: any[]
}

// 素材题目管理 VO
export interface QuestionVO {
  id: number // id
  content: string // 题干
  type: string // 题目类型1单选2多选3判断4简单5填空
  questionType: number // 题目目录
  difficulty: number // 题目难度1简单2中等3困难
  analysis: string // 题目解析
  answer: string // 题目解析
}

// 题型定义
export enum QuestionType {
  SINGLE = 'single',
  MULTIPLE = 'multiple',
  JUDGE = 'judge',
  SHORT = 'short',
  BLANK = 'blank'
}

// 题型配置
export const QUESTION_TYPE_CONFIG = [
  { type: QuestionType.SINGLE, label: '单选题' },
  { type: QuestionType.MULTIPLE, label: '多选题' },
  { type: QuestionType.JUDGE, label: '判断题' },
  { type: QuestionType.SHORT, label: '简答题' },
  { type: QuestionType.BLANK, label: '填空题' }
]

// 创建题目列表
export const createQuestionList = (data: QuestionListParams) => {
  return request.post({ url: '/material/question/create', data })
}

export const getQuestionPage = (params: any) => {
  return request.get({ url: `/material/question/page`, params })
}

export const getTypeCount = (params: any) => {
  return request.get({ url: `/material/question/getTypeCount`, params })
}

export const getTypeAndQuestionCount = (params: any) => {
  return request.get({ url: `/material/question/getTypeAndQuestionCount`, params })
}

// 删除素材
export const deleteQuestion = async (id: number) => {
  return await request.delete({ url: '/material/question/delete?id=' + id })
}

export const getQuestion = async (id: number) => {
  return await request.get({ url: '/material/question/getDetail?id=' + id })
}
